var app = require("lzbjpk_app");

/**
 * 类构造
 */
var BJPKRoomSet = app.BaseClass.extend({

	/**
	 * 初始化
	 */
	Init:function(){

		this.JS_Name = "BJPKRoomSet";

		this.ComTool = app[app.subGameName + "_ComTool"]();
		this.ShareDefine = app[app.subGameName + "_ShareDefine"]();
		this.PokerCard=app[app.subGameName.toUpperCase()+"PokerCard"]();
		this.allSetPosDict = {};
		this.cacheSetPosDict = {};
		this.OnReload();
		console.log("Init");

	},
	OnReload:function(){
		for(let posID in this.allSetPosDict){
			let setPos = this.allSetPosDict[posID];
			setPos.OnReload();
			this.cacheSetPosDict[posID] = setPos
		}
		this.allSetPosDict = {};

		//{
		//	"setID":0,
		//	"dPos":0,
		//	"startPaiPos":0,
		//	"startPaiDun":0,
		//	"state":0,
		//	"setEnd":{"posHuList":posHuList,"maCardList":maCardList,"zhongMa":0},
		//}
		this.dataInfo = {};
		this.dataInfo["totalChip"] = 0;
		this.dataInfo["curChip"] = 0;
		this.dataInfo["curOpPos"] = 0;
		this.dataInfo["shouCard"] = [];

	},
	InitSetInfo:function(setInfo){
		console.log('InitSetInfo', setInfo);

		this.dataInfo = setInfo;
		if (this.dataInfo["state"] == "End") {
			this.GetSortOutSetEnd(this.dataInfo["setEnd"]["sRankingResult"]);
		}
	},
	SetState:function(state){
		this.dataInfo['state']=state;
	},
	//prizePoint
	ClearPrizePoint: function (datapos) {
		let posInfo = this.dataInfo["setPosList"];
		for (let i = 0; i < posInfo.length; i++) {
			if (posInfo[i].posID == datapos) posInfo[i]['prizePoint'] = 0;
		}
	},
	SetPrizePoint: function (datapos, prizePoint) {
		let posInfo = this.dataInfo["setPosList"];
		for (let i = 0; i < posInfo.length; i++) {
			if (posInfo[i].posID == datapos) posInfo[i]['prizePoint'] = prizePoint;
		}
	},
	GetPrizePoint:function(datapos){
		let posInfo = this.dataInfo["setPosList"];
		for(let i = 0; i < posInfo.length; i++){
			if(posInfo[i].posID ==datapos){
				return posInfo[i]['prizePoint'];
			}
		}
	},
	GetLiPais:function(){
		let posInfo = this.dataInfo["setPosList"];
		for(let i = 0; i < posInfo.length; i++){
			if(posInfo[i].pid == app[app.subGameName + "_HeroManager"]().GetHeroProperty("pid")){
				return posInfo[i]['liPais'];
			}
		}
	},
	SetLiPais:function(lipais){
		let posInfo = this.dataInfo["setPosList"];
		for(let i = 0; i < posInfo.length; i++){
			if(posInfo[i].pid == app[app.subGameName + "_HeroManager"]().GetHeroProperty("pid")){
				posInfo[i]['liPais']=lipais;
			}
		}
	},
	SetPoint: function (datapos, point) {
		let posInfo = this.dataInfo["setPosList"];
		for (let i = 0; i < posInfo.length; i++) {
			if (posInfo[i].posID == datapos) posInfo[i]['point'] = point;
		}
	},
	GetPoint:function(datapos){
		let posInfo = this.dataInfo["setPosList"];
		for(let i = 0; i < posInfo.length; i++){
			if(posInfo[i].posID ==datapos){
				return posInfo[i]['point'];
			}
		}
	},
	SetRanksType:function(datapos,ranksType){
		let posInfo = this.dataInfo["setPosList"];
		for(let i = 0; i < posInfo.length; i++){
			if(posInfo[i].posID ==datapos){
				posInfo[i]['ranksType']=ranksType;
			}
		}
	},
	GetRanksType:function(datapos){
		let posInfo = this.dataInfo["setPosList"];
		for(let i = 0; i < posInfo.length; i++){
			if(posInfo[i].posID ==datapos){
				return posInfo[i]['ranksType'];
			}
		}
	},

	SetWasteKings:function(datapos,wasteKings){
		let posInfo = this.dataInfo["setPosList"];
		for(let i = 0; i < posInfo.length; i++){
			if(posInfo[i].posID ==datapos){
				posInfo[i]['wasteKings']=wasteKings;
			}
		}
	},
	GetWasteKings:function(datapos){
		let posInfo = this.dataInfo["setPosList"];
		for(let i = 0; i < posInfo.length; i++){
			if(posInfo[i].posID ==datapos){
				return posInfo[i]['wasteKings'];
			}
		}
	},
	GetEndPosType:function(datapos){
		let posInfo = this.dataInfo["setPosList"];
		for(let i = 0; i < posInfo.length; i++){
			if(posInfo[i].posID ==datapos){
				return posInfo[i]['endPosType'];
			}
		}
	},

	GetPosHandCard:function(datapos){
		//return [66,66,66,66,66];
		let posInfo = this.dataInfo["setPosList"];
		for(let i = 0; i < posInfo.length; i++){
			if(posInfo[i].posID ==datapos){
				if(this.SortType==1){
					return this.SortCardByMax(posInfo[i]['privateCards']);
				}else if(this.SortType==2){
					return this.SortCardByNum(posInfo[i]['privateCards']);
				}

			}
		}
		return [];
	},
	GetPosRootCarsSize:function(datapos){
		//return [66,66,66,66,66];
		let posInfo = this.dataInfo["setPosList"];
		for(let i = 0; i < posInfo.length; i++){
			if(posInfo[i].posID ==datapos){
				return posInfo[i]['rootCarsSize'];

			}
		}
		return 0;
	},
	ClearAllOutCards:function(){
		let posInfo = this.dataInfo["setPosList"];
		for(let i = 0; i < posInfo.length; i++){
			posInfo[i]['curOutCards']=[];
		}
	},
	GetPosOutCards:function(datapos){
		let posInfo = this.dataInfo["setPosList"];
		for(let i = 0; i < posInfo.length; i++){
			if(posInfo[i].posID ==datapos){
				return posInfo[i]['curOutCards'];
			}
		}
		return [];
	},
	SetPosOutCards:function(datapos){
		let posInfo = this.dataInfo["setPosList"];
		for(let i = 0; i < posInfo.length; i++){
			if(posInfo[i].posID ==datapos){
				posInfo[i]['curOutCards']=[];
			}
		}
	},
	SetCurChipValue: function (curChip) {
		this.dataInfo["curChip"] = curChip;
		this.SetTotalChipValue(curChip);
	},
	GetCurChipValue: function () {
		let curChip = this.dataInfo["curChip"];
		return curChip;
	},
	SetCurOpPos: function (curOpPos) {
		this.dataInfo["curOpPos"] = curOpPos;
	},
	SetTotalChipValue: function (totalChip) {
		this.dataInfo["totalChip"] += totalChip;
	},
	GetTotalChipValue: function () {
		let totalChip = this.dataInfo["totalChip"];
		return totalChip;
	},
	GetPosLastChipValue: function (pos) {
		let posInfo = this.dataInfo["setPosList"];
		for (let i = 0; i < posInfo.length; i++) {
			if (posInfo[i].posID == pos) {
				return posInfo[i]['chipValue'];
			}
		}
		return [];
	},
	GetPosChipValue: function (pos) {
		let posInfo = this.dataInfo["setPosList"];
		for (let i = 0; i < posInfo.length; i++) {
			if (posInfo[i].posID == pos) {
				return posInfo[i]['chip'];
			}
		}
		return [];
	},
	InitSetPosList:function(setPosList){
		let count = setPosList.length;
		for(let posID in this.allSetPosDict){
			let setPos = this.allSetPosDict[posID];
			setPos.OnReload();
			this.cacheSetPosDict[posID] = setPos
		}
		this.allSetPosDict = {};
		for(let index=0; index < count; index++){
			let setPosInfo = setPosList[index];
			let posID = setPosInfo["posID"];

			//获取缓存的setPos对象
			let setPos = this.cacheSetPosDict[posID];
			delete this.cacheSetPosDict[posID];
			setPos.OnInitSetPos(setPosInfo);
			this.allSetPosDict[posID] = setPos
		}
	},
	//-----------------------回调函数-----------------------------
	OnInitRoomSetData:function(setInfo){
		this.InitSetInfo(setInfo);
		let state = this.dataInfo["state"];
		let stateStr = null;
		if (!isNaN(state)) {//如果是数字
			let stateList = ["Init", "Playing", "End", "Waiting"];
			stateStr = stateList[state];
		} else {
			stateStr = state;
		}
		if(this.ShareDefine.SetStateStringDict.hasOwnProperty(stateStr)){
			this.dataInfo["state"] = this.ShareDefine.SetStateStringDict[stateStr];
		}
		else{
			console.error("OnInitRoomSetData state:%s not find", state, stateStr);
		}
	},

	OnPosLeave:function(pos){
		let setPos = this.allSetPosDict[pos];
		//可能未开局没有allSetPosDict数据
		if(!setPos){
			console.log("OnPosLeave(%s) not find", pos);
			return;
		}
		delete this.allSetPosDict[pos];
		this.cacheSetPosDict[pos] = setPos;
	},

	OnPosContinueGame:function(){
		// this.dataInfo["state"] = this.ShareDefine.SetState_Init;
		for(let pos in this.allSetPosDict){
			this.allSetPosDict[pos].OnPosContinueGame();
		}
	},

	OnSetStart:function(setInfo){
		this.InitSetInfo(setInfo);
		this.dataInfo["state"] = this.ShareDefine.SetState_Playing;
		this.dataInfo["totalChip"] = 1;//游戏开始筹码为1
	},

	OnSetKanPai: function (pos, kanInfo) {
		let posList = this.dataInfo["setPosList"];
		for (let i = 0; i < posList.length; i++) {
			let posInfo = posList[i];
			if (posInfo["posID"] == pos) {
				let privateCards = kanInfo["privateCards"];
				let value = kanInfo["value"];
				posInfo["privateCards"] = privateCards;
				posInfo["value"] = value;
			}
		}
	},
	OnSetEnd:function(setEnd){
		this.dataInfo["setEnd"] = setEnd;
		this.dataInfo["state"] = this.ShareDefine.SetState_End;

		let posInfo = this.dataInfo["setPosList"];
		for(let i = 0; i < posInfo.length; i++){
			this.dataInfo["setPosList"][i]['shouCard']=[];
		}


		this.GetSortOutSetEnd(this.dataInfo["setEnd"]["sRankingResult"]);
	},
	GetSortOutSetEnd: function (setEnd) {
		let clientPos = app[app.subGameName.toUpperCase()+"RoomPosMgr"]().GetClientPos();
		let playerResults = setEnd["playerResults"];
		// let playerResults = setEnd["posResultList"];
		let pResult1 = setEnd["pResult1"];
		let pResult2 = setEnd["pResult2"];
		let pResult3 = setEnd["pResult3"];

		let pCard1 = setEnd["pCard1"];
		let pCard2 = setEnd["pCard2"];
		let pCard3 = setEnd["pCard3"];
		for (let i = 0; i < pCard1.length; i++) {
			pCard1[i]["score"] = pResult1[i]["score"];
			pCard1[i]["rewardScore"] = pResult1[i]["rewardScore"];
			// pCard1[i]["allScore"] = pResult1[i]["allScore"];
			if (clientPos == pCard1[i]["posID"]) {
				if (pCard1[i]["cards"].length == 0) {
					pCard1[i]["cards"] = [0,0,0];
				}
				this.SetRoomProperty("DUN1", pCard1[i]["cards"]);
			}
		}
		for (let j = 0; j < pCard2.length; j++) {
			pCard2[j]["score"] = pResult2[j]["score"];
			pCard2[j]["rewardScore"] = pResult2[j]["rewardScore"];
			// pCard2[j]["allScore"] = pResult2[j]["allScore"];
			if (clientPos == pCard2[j]["posID"]) {
				if (pCard1[j]["cards"].length == 0) {
					pCard1[j]["cards"] = [0,0,0];
				}
				this.SetRoomProperty("DUN2", pCard2[j]["cards"]);
			}
		}
		for (let k = 0; k < pCard3.length; k++) {
			pCard3[k]["score"] = pResult3[k]["score"];
			pCard3[k]["rewardScore"] = pResult3[k]["rewardScore"];
			// pCard3[k]["allScore"] = pResult3[k]["allScore"];
			if (clientPos == pCard3[k]["posID"]) {
				if (pCard1[k]["cards"].length == 0) {
					pCard1[k]["cards"] = [0,0,0];
				}
				this.SetRoomProperty("DUN3", pCard3[k]["cards"]);
			}
		}

		/*pCard1.sort((a, b) => {
			return a["order"] - b["order"];
		});
		pCard2.sort((a, b) => {
			return a["order"] - b["order"];
		});
		pCard3.sort((a, b) => {
			return a["order"] - b["order"];
		});*/

		pCard1.sort((a, b) => {
			return a["posID"] - b["posID"];
		});
		pCard2.sort((a, b) => {
			return a["posID"] - b["posID"];
		});
		pCard3.sort((a, b) => {
			return a["posID"] - b["posID"];
		});
		console.log("小局结束Event_SetEnd", setEnd);
		let rewardsDict = {};
		for (let l = 0; l < playerResults.length; l++) {
			let playerResult = playerResults[l];
			let posID = playerResult["posID"];
			let rewards = playerResult["rewards"];
			let score = playerResult["score"];
			let allScore = playerResult["allScore"];
			let roomScore = playerResult["roomScore"];
			let sportsPoint = playerResult["sportsPoint"];
			if (!rewardsDict[posID]) {
				rewardsDict[posID] = [];
			}
			rewardsDict[posID]["rewards"] = rewards;
			rewardsDict[posID]["score"] = score;
			rewardsDict[posID]["allScore"] = allScore;
			rewardsDict[posID]["roomScore"] = roomScore;
			rewardsDict[posID]["sportsPoint"] = sportsPoint;
		}
		this.SetRoomProperty("rewardsDict", rewardsDict);
		//获取服务端整理好发过来的牌

	},
	GetGameState: function () {
		return this.dataInfo["state"];
	},
	OnStartRound:function(setRound){
		this.dataInfo["setRound"] = setRound;
		let waitOpPos = setRound["opPosList"][0]["waitOpPos"];
		this.SetCurOpPos(waitOpPos);
	},
	OnSetPosList: function (setPosList) {
		this.dataInfo["setPosList"] = setPosList;
	},

	//指定位置获取卡牌
	OnPosGetCard:function(pos, setPosInfo, normalMoCnt, gangMoCnt){
		let setPos = this.allSetPosDict[pos];
		if(!setPos){
			console.error("OnPosGetCard not find(%s)", pos);
			return false
		}
		this.dataInfo["normalMoCnt"] = normalMoCnt;
		this.dataInfo["gangMoCnt"] = gangMoCnt;

		return setPos.OnPosGetCard(setPosInfo);
	},
	SetRoomSetProperty:function(key,value){
		this.dataInfo[key] = value;
	},
	OnPosOpCard:function(serverPack){
		let pos = serverPack["pos"];
		let opType = serverPack["opType"];
		let chip = serverPack["chip"];
		this.dataInfo["setPosList"][pos]['chip'] += chip;
		console.log("dataInfo:", this.dataInfo);
	},

	//删除掉已经打出去的牌
	OnDeleteOutCard:function(cardID){
		let findPos = -1;

		for(let pos in this.allSetPosDict){
			let setPos = this.allSetPosDict[pos];
			let outCard = setPos.GetSetPosProperty("outCard");
			//如果找到需要删除的卡牌
			if(outCard.InArray(cardID)){
				outCard.Remove(cardID);
				findPos = pos;
				break
			}
		}

		return findPos
	},

	//添加打出去的牌
	OnAddOutCard:function(pos,cardID){
		let setPos = this.allSetPosDict[pos];
		let outCard = setPos.GetSetPosProperty("outCard");
		//如果找到需要删除的卡牌
		if(outCard.InArray(cardID)){
			return false;
		}else{
			outCard.push(cardID);
			return true;
		}
	},

	//----------------获取接口--------------------

	//获取set属性值
	GetRoomSetProperty:function(property){
		if(!this.dataInfo.hasOwnProperty(property)){
			console.error("GetSetProperty(%s) not find", property);
			return
		}
		return this.dataInfo[property];
	},

	GetRoomSetInfo:function(){
		return this.dataInfo
	},

	GetSetPosByPos:function(pos){
		if(pos==-1){
			return
		}
		let setPos = this.allSetPosDict[pos];
		if(!setPos){
			console.error("GetSetPosByPos not find:%s", pos);
			return
		}
		return setPos
	},

	//获取指定类型的卡牌剩余未出数量
	GetHuCardTypeInfo:function(selfPos){

		let outCardIDList = [];
		let selfSetPos = this.allSetPosDict[selfPos];
		if(!selfSetPos){
			console.error("GetHuCardLeftInfo not find selfPos:%s", selfPos);
			return {}
		}

		for(var pos in this.allSetPosDict){
			let setPos = this.allSetPosDict[pos];

			//如果是本家,需要加上手卡
			if(selfPos == pos){
				outCardIDList = outCardIDList.concat(setPos.GetSetPosProperty("shouCard"));
				let handCard = setPos.GetSetPosProperty("handCard");
				if(handCard > 0){
					outCardIDList.push(handCard);
				}
			}
			//加上打出去的牌
			outCardIDList = outCardIDList.concat(setPos.GetSetPosProperty("outCard"));

			//加上吃到的牌
			let publicCardList = setPos.GetSetPosProperty("publicCardList");
			let publicCount = publicCardList.length;
			for(let index=0; index<publicCount; index++){
				let publicInfoList = publicCardList[index];
				let cardIDList = publicInfoList.slice(3, publicInfoList.length);
				outCardIDList = outCardIDList.concat(cardIDList);
			}
		}

		outCardIDList.SortList();

		let allCardTypeDict = {};
		let allCount = outCardIDList.length;
		for(let index=0; index<allCount; index++){
			let cardID = outCardIDList[index];
			let cardType = Math.floor(cardID/100);

			if(allCardTypeDict.hasOwnProperty(cardType)){
				allCardTypeDict[cardType] += 1;
			}
			else{
				allCardTypeDict[cardType] = 1;
			}
		}

		let huCardTypeInfo = {};
		let huCardTypeList = selfSetPos.GetSetPosProperty("huCard");
		let count = huCardTypeList.length;
		for(var index=0; index<count; index++){
			let cardType = huCardTypeList[index];
			let leftCount = 4;
			if(allCardTypeDict.hasOwnProperty(cardType)){
				leftCount = 4 - allCardTypeDict[cardType];
			}
			huCardTypeInfo[cardType] = leftCount;
		}

		console.log("huCardTypeInfo:", huCardTypeInfo);
		return huCardTypeInfo
	},
	SortCardByNum: function (pokers) {
		let GuiPai = [];
		let NewPai = [];
		let _t = this;
		let countList = new Array();
		for (let i = 0; i < pokers.length; i++) {
			// let cardColor = this.PokerCard.GetCardColor(pokers[i]);
			let cardValue = this.PokerCard.GetCardValue(pokers[i]);
			if (cardValue <= 2) {
				GuiPai.push(pokers[i]);
			} else {
				NewPai.push(pokers[i]);
				if (countList[cardValue]) {
					countList[cardValue]['num']++;
				} else {
					countList[cardValue] = new Array();
					countList[cardValue]['num'] = 1;
					countList[cardValue]['cardValue'] = cardValue;
				}

			}
		}
		//先添加鬼牌在最左边start
		GuiPai.sort(function (a, b) {
			return (b & 0x0F) - (a & 0x0F);
		});
		let Sortpokers = [];
		for (let i = 0; i < GuiPai.length; i++) {
			Sortpokers.push(GuiPai[i]);
		}
		//先添加鬼牌在最左边finish
		countList.sort(function (a, b) {
			if (b.num == a.num) {
				return b.cardValue - a.cardValue;
			}
			return b.num - a.num;
		});

		NewPai.sort(function (a, b) {
			let avalue = _t.PokerCard.GetCardValue(a);
			let bvalue = _t.PokerCard.GetCardValue(b);
			if (avalue == bvalue) {
				let aColor = _t.PokerCard.GetCardColor(a);
				let bColor = _t.PokerCard.GetCardColor(b);
				return bColor - aColor;
			} else {
				return (b & 0x0F) - (a & 0x0F);
			}

		});
		for (let j = 0; j < countList.length; j++) {
			if (countList[j]) {
				if (countList[j]['num'] > 0) {
					for (let k = 0; k < NewPai.length; k++) {
						let NewPaiVal = this.PokerCard.GetCardValue(NewPai[k]);
						let countVal = countList[j]['cardValue'];
						if (NewPaiVal == countVal) {
							Sortpokers.push(NewPai[k]);
						}
					}

				}
			}
		}
		return Sortpokers;
	},
	SortCardByMax:function(pokers){
		let GuiPai=[];
		let NewPai=[];
		let _t = this;
		for(let i=0;i<pokers.length;i++){
			let cardColor = this.PokerCard.GetCardColor(pokers[i]);
			let cardValue = this.PokerCard.GetCardValue(pokers[i]);
			if(cardValue<=2){
				GuiPai.push(pokers[i]);
			}else{
				NewPai.push(pokers[i]);
			}
		}
		NewPai.sort(function(a, b){
			let avalue=_t.PokerCard.GetCardValue(a);
			let bvalue=_t.PokerCard.GetCardValue(b);
			if(avalue==bvalue){
				let aColor=_t.PokerCard.GetCardColor(a);
				let bColor=_t.PokerCard.GetCardColor(b);
				return bColor - aColor;
			}else{
				return (b&0x0F) - (a&0x0F);
			}

		});
		GuiPai.sort(function(a, b){
			return (b&0x0F) - (a&0x0F);
		});
		let Sortpokers=[];
		for(let i=0;i<GuiPai.length;i++){
			Sortpokers.push(GuiPai[i]);
		}
		for(let i=0;i<NewPai.length;i++){
			Sortpokers.push(NewPai[i]);
		}
		return Sortpokers;
	},

	SortCardByMin:function(pokers){
		console.log('===========LZBJPKRoomSet==SortCardByMin===========',pokers)
		let GuiPai=[];
		let NewPai=[];
		let _t = this;
		for(let i=0;i<pokers.length;i++){
			// let cardColor = this.PokerCard.GetCardColor(pokers[i]);
			let cardValue = this.PokerCard.GetCardValue(pokers[i]);
			if(cardValue<=2){
				GuiPai.push(pokers[i]);
			}else{
				NewPai.push(pokers[i]);
			}
		}
		NewPai.sort(function(a, b){
			let avalue=_t.PokerCard.GetCardValue(a);
			let bvalue=_t.PokerCard.GetCardValue(b);
			if(avalue==bvalue){
				let aColor=_t.PokerCard.GetCardColor(a);
				let bColor=_t.PokerCard.GetCardColor(b);
				return bColor - aColor;
			}else{
				return (a&0x0F) - (b&0x0F);
			}

		});
		GuiPai.sort(function(a, b){
			return (a&0x0F) - (b&0x0F);
		});
		let Sortpokers=[];
		for(let i=0;i<NewPai.length;i++){
			Sortpokers.push(NewPai[i]);
		}
		for(let i=0;i<GuiPai.length;i++){
			Sortpokers.push(GuiPai[i]);
		}
		/*console.log("GuiPai", GuiPai);
		console.log("NewPai", NewPai);
		console.log("Sortpokers", Sortpokers);*/
		return Sortpokers;
	},
	GetRoomProperty:function(property){
		if(!this.dataInfo.hasOwnProperty(property)){
			console.error("GetRoomProperty not find:%s", property);
			return
		}
		return this.dataInfo[property];
	},
	SetRoomProperty:function(key, data){
		this.dataInfo[key] = data;
	},
	GetNoSortHandCard: function () {
		let posInfo = this.dataInfo["setPosList"];
		let privateCards = [];
		let clientPos = -1;
		for (let i = 0; i < posInfo.length; i++) {
			if (posInfo[i].pid == app[app.subGameName + "_HeroManager"]().GetHeroProperty("pid")) {
				clientPos = i;
				privateCards = posInfo[i]['privateCards'];
				break;
			}
		}
		return privateCards;
	},
/*	GetHandCard:function(){
		let posInfo = this.dataInfo["setPosList"];
		let privateCards=[];
		let clientPos=-1;
		for(let i = 0; i < posInfo.length; i++){
			if(posInfo[i].pid == app[app.subGameName + "_HeroManager"]().GetHeroProperty("pid")){
				clientPos=i;
				if(this.SortType==1){
					privateCards=this.SortCardByMax(posInfo[i]['privateCards']);
				}else if(this.SortType==2){
					privateCards=this.SortCardByNum(posInfo[i]['privateCards']);
				}
				break;
			}
		}
		//重新排序
		let liPais=this.GetLiPais(clientPos);
		if(liPais.length>0){
			let newPrivateCards=[];
			let newCardsEXLiPais = [];
			let newSortCards = [];
			for(let i=0;i<liPais.length;i++){
				for(let j=0;j<liPais[i].length;j++){
					newPrivateCards.push(liPais[i][j]);
				}
			}
			/!*for(let i=0;i<privateCards.length;i++){
				if(!newPrivateCards.InArray(privateCards[i])){
					newPrivateCards.push(privateCards[i]);
				}
			}*!/
			for (let i = 0; i < privateCards.length; i++) {//移除手牌中理牌的牌
				if (newPrivateCards.indexOf(privateCards[i]) == -1) {
					newCardsEXLiPais.push(privateCards[i]);
				}
			}
			//进行牌排序
			//合并所有的牌牌
			if (this.SortType == 1) {
				newSortCards = this.SortCardByMax(newCardsEXLiPais);
			} else if (this.SortType == 2) {
				newSortCards = this.SortCardByNum(newCardsEXLiPais);
			}
			for (let i = 0; i < newSortCards.length; i++) {
				newPrivateCards.push(newSortCards[i]);
			}
			return newPrivateCards; //重新理牌的排数
		}
		return privateCards;
	},	*/

	GetHandCard:function(){
		let posInfo = this.dataInfo["setPosList"];
		let setPos = this.dataInfo["posInfo"];
		let privateCards=[];
		let clientPos=-1;
		for(let i = 0; i < posInfo.length; i++){
			if(setPos[i].pid == app[app.subGameName + "_HeroManager"]().GetHeroProperty("pid")){
				clientPos=i;
				privateCards=posInfo[i]['shouCard'];
				break;
			}
		}
		return privateCards;
	},

});


var g_BJPKRoomSet = null;

/**
 * 绑定模块外部方法
 */
exports.GetModel = function(){
	if(!g_BJPKRoomSet)
		g_BJPKRoomSet = new BJPKRoomSet();
	return g_BJPKRoomSet;

};